package com.marchsoft.musicalstore.repository;

import com.marchsoft.musicalstore.entity.SelClassAble;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;


import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 源
 * Date: 2019-11-17
 * Time: 11:21
 */
public interface SelClassAbleRepository extends JpaRepository<SelClassAble,Integer> {
    //分页查询可选课程
    List<SelClassAble> findByTypeAndCourseId(int type, int courseId, Pageable page);
    List<SelClassAble> findByType(int type, Pageable page);

    List<SelClassAble> findByTeacherId(Integer teacherId);

    //查看全部可选课程
    List<SelClassAble> findAllByOrderByPassPeonumDesc();
    //搜索课程
    List<SelClassAble> findByNameAndTypeAndCourseId(String name,int type,Pageable b,int courseId);

    //源联合两个表查询某天的课程
    @Query(value = "select *  from selclassable,stucourse where selclassable.id=stucourse.pick_classid and stucourse.stu_id=? and selclassable.course_time=?"
            ,nativeQuery=true)
    List<SelClassAble> queryAllByStuId(Integer stuId,Integer course_time);



}
